<?php

class HistoryController extends AdminController {    
    
    public function actionIndex() {
        $model = new History('search');
        $model->unsetAttributes();  // clear any default values
        if (isset($_GET['History']))
            $model->attributes = $_GET['History'];
        $this->render('index', array(
          'model' => $model,
        ));
	
    }
    
    public function loadModel() {
        $model = null;
        if (isset($_GET['id']))
        {
            $ids = explode(',', $_GET['id']);
            if (isset($ids)) {
                $criteria = new CDbCriteria;
                $criteria->addInCondition('object_id', $ids);
                $model = History::model()->findAll($criteria);
            }         
        }
        return $model;
        
    }
    
    public function actionProfile(){
    	if (isset($_GET['id'])){
    		$profile_id = $_GET['id'];
    		$criteria = new CDbCriteria;
    		$criteria->together = true;
    		$criteria->with = array (
    				'profileJP'
    		);
    		$criteria->compare('t.id', $profile_id);
    		$profile=Profile::model()->findAll($criteria);
    		
			$model = new History("history");
			if (isset($_GET['History']))
				$model->attributes = $_GET['History'];
	    	$this->render('index', array(
	    			'model' => $model, "profileModel" => $profile[0]
	    	));
    	}
    }
}

?>